﻿<Window x:Class="Sample.SecuritiesWindow"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
	xmlns:EcngTradingXaml="clr-namespace:StockSharp.Xaml;assembly=StockSharp.Xaml"
	x:Name="x_securitiesWindow" Title="Инструменты" Height="415" Width="1081">
	<Window.Resources>
		<EcngTradingXaml:BackgroundConvertor x:Key="myConverter" />
		<EcngTradingXaml:QuoteConverter x:Key="quoteConverter" />

		<Style x:Key="myItemStyle" TargetType="{x:Type ListViewItem}">
			<Setter Property="Background">
				<Setter.Value>
					<Binding RelativeSource="{RelativeSource Self}" Converter="{StaticResource myConverter}"/>
				</Setter.Value>
			</Setter>
			<Setter Property="HorizontalContentAlignment" Value="Stretch" />
			<Setter Property="VerticalContentAlignment" Value="Stretch" />
		</Style>
	</Window.Resources>
	<Grid>
		<Grid.RowDefinitions>
			<RowDefinition Height="*" />
			<RowDefinition Height="Auto" />
		</Grid.RowDefinitions>
		
		<ListView x:Name="x_SecuritiesDetails" Grid.Column="0" Grid.Row="0" ItemContainerStyle="{StaticResource myItemStyle}" ItemsSource="{Binding ElementName=x_securitiesWindow, Path=Securities}" SelectionChanged="SecuritiesDetailsSelectionChanged">
			<ListView.View>
				<GridView>
					<GridViewColumn Width="120" Header="Название" DisplayMemberBinding="{Binding Path=Name}" />
					<GridViewColumn Width="100" Header="Код" DisplayMemberBinding="{Binding Path=Code}" />
					<GridViewColumn Width="60" Header="Класс" DisplayMemberBinding="{Binding Path=Class}" />
					<GridViewColumn Width="150" Header="Bid" DisplayMemberBinding="{Binding Path=BestBid, Converter={StaticResource quoteConverter}}" />
					<GridViewColumn Width="150" Header="Ask" DisplayMemberBinding="{Binding Path=BestAsk, Converter={StaticResource quoteConverter}}" />
					<GridViewColumn Width="140" Header="Послед. сделка" DisplayMemberBinding="{Binding Path=LastTrade.Time, FallbackValue=NULL}" />
					<GridViewColumn Width="100" Header="Послед. цена" DisplayMemberBinding="{Binding Path=LastTrade.Price, FallbackValue=NULL}" />
					<GridViewColumn Width="90" Header="Послед. кол-во" DisplayMemberBinding="{Binding Path=LastTrade.Volume, FallbackValue=NULL}" />
					<GridViewColumn Width="40" Header="Лот" DisplayMemberBinding="{Binding Path=MinLotSize}" />
					<GridViewColumn Width="60" Header="Точность" DisplayMemberBinding="{Binding Path=Decimals}" />
					<GridViewColumn Width="40" Header="Шаг" DisplayMemberBinding="{Binding Path=MinStepSize}" />
				</GridView>
			</ListView.View>
		</ListView>
		
		<Grid Grid.Row="1" HorizontalAlignment="Right">
			<Grid.ColumnDefinitions>
				<ColumnDefinition Width="Auto" />
				<ColumnDefinition Width="Auto" />
				<ColumnDefinition Width="Auto" />
			</Grid.ColumnDefinitions>

			<Button x:Name="Quotes" Grid.Column="0" Content="Стакан..." Width="100" IsEnabled="False" Click="QuotesClick" />
			<Button x:Name="NewOrder" Grid.Column="1" Content="Новая заявка..." Width="100" IsEnabled="False" Click="NewOrderClick" />
			<Button x:Name="NewStopOrder" Grid.Column="2" Content="Новая стоп-заявка..." Width="120" IsEnabled="False" Click="NewStopOrderClick" />
		</Grid>
	</Grid>
</Window>
